

from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from untils.random_email import random_email


class Testcase_fqz():
    def Testcase_fqz(self):
        pass

    def setup(self):
        # 打开浏览器并放大
        self.driver = webdriver.Chrome("C:\Program Files\Python38\chromedriver.exe")
        self.driver.get("https://www.glp.com.cn/business/logistics_industry.html#")
        # self.driver.get("https://stgweb.glp.com.cn/about/glp.html")
        self.driver.maximize_window()
        time.sleep(3)

    #首页搜索按钮：搜索“普洛斯”相关内容
    def test_search(self):
        #搜索按钮
        self.driver.find_element(By.XPATH,'/html/body/div/header/div[2]/div/div[2]/div[1]/span[3]/a/img').click()
        self.driver.find_element(By.XPATH,'/html/body/div/div[12]/div/input').send_keys('普洛斯',Keys.ENTER)
        # self.driver.find_element(By.ID,'subscribe_mail').send_keys('12@d22.com')
        time.sleep(3)
    #业务联络
    def test_business_liaison(self):
        self.driver.find_element(By.XPATH,'/html/body/div/div[2]/div[2]/div[6]/div/ul/li[1]/a/p[1]').click()
        self.driver.find_element(By.XPATH,'//*[@id="ywll-container"]/div/div[1]/div/div[1]/ul/li[1]/label/span[2]').click()
        # self.driver.find_element(By.XPATH,'//*[@id="ywll-container"]/div/div[1]/div/div[1]/ul/li[1]/label/span[2]')
        # self.driver.find_element(By.XPATH,'//*[@id="name"]').send_keys('张三')
        # self.driver.find_element(By.XPATH,'//*[@id="email"]').send_keys(random_email())
        time.sleep(10)
        self.driver.find_element(By.XPATH,'//*[@id="positions"]').send_keys('经理')
        time.sleep(10)
        self.driver.find_element(By.XPATH,'//*[@id="company"]').send_keys('表单数据提交测试')
        self.driver.find_element(By.XPATH,'//*[@id="phone"]').send_keys("17424394394")
        # self.driver.find_element(By.XPATH,'//*[@id="send_verify"]').click()
        #输入验证码
        self.driver.find_element(By.XPATH,'//*[@id="code"]').send_keys('w000')
        self.driver.find_element(By.XPATH,'//*[@id="ywll-container"]/div/div[2]/div/div[5]/label/span[1]').click()
        self.driver.find_element(By.XPATH,'//*[@id="ywll-container"]/div/div[2]/div/div[6]/button').click()
        time.sleep(20)

    #联系我们（搜索）
    def test_contact_search(self):
        self.driver.find_element(By.LINK_TEXT,'联系我们').click()
        time.sleep(3)
        self.driver.find_element(By.XPATH,'//*[@id="selectKW"]').send_keys('普洛斯供应链')
        ele = '//*[@id="contactUsSearch"]'
        ele1 = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.XPATH,ele)))
        # print(ele1.text)
        ele1.click()

        time.sleep(3)
    #
    # #订阅“普洛斯纵览”
    # def test_subscribe(self):
    #     self.driver.find_element(By.XPATH,'//*[@id="subscribe_mail"]').send_keys(handle_data.random_email())
    #     self.driver.find_element(By.XPATH,'//*[@id="email-glp"]/ul/li[2]/div/div/button').click()
    #     time.sleep(10)
    #
    # #园区搜索
    # def test_park(self):
    #     el = self.driver.find_element(By.LINK_TEXT,'我们的业务')
    #     ActionChains(self.driver).move_to_element(el).perform()
    #     self.driver.find_element(By.CSS_SELECTOR,'$x("//*[@id="form-input"]")[0]').send_keys('普洛斯')
    #     # self.driver.find_element(By.XPATH,'/html/body/div/header/div/div/div[1]/div[1]/ul/li[2]/ul/li[8]/div/div/img').click()
    #     time.sleep(5)


    def teardown(self):
        print("不关闭")
        # quit()
# driver = webdriver.Chrome(r"D:\chromedriver.exe")
# driver.get("https://www.glp.com.cn/")
# driver.maximize_window()
# driver.find_element(By.XPATH,'//*[@id="subscribe_mail"]').send_keys("123@hh.com")